
/* 渲染商品详情页 */
(function () {
    // 获取详情页面地址
    let url = location.href
    console.log(url);
    let urlObj = getQueryString(url)
    console.log(urlObj.productid);

    // 发送请求获取数据 带上从首页获取过来的 urlObj.productId 参数
    fetch('http://chst.vip:1234/api/getmoneyctrlproduct?productid=' + urlObj.productid)
        .then(response => {
            return response.json()
        }).then(data => {
            let res = data.result[0]
            console.log(res);
            let regExp = /(?<=imgurl=)[^'"]*/;
            let img = regExp.exec(res.productImg2)[0]
            let ele = `
                 <li>
                    <div class="inFor">
                        <div class="title">
                            <h4>${res.productName}</h4>
                        </div>
                        <div class="other">
                            <span class="mall">${res.productFrom} | ${res.productTime}</span>
                            <i>${res.productTips}</i>
                        </div>
                        <div class="container">
                            <img src="${img}" alt="">
                            <p>
                                ${res.productInfo}
                                ${res.productInfo1}
                                ${res.productInfo2}
                            </p>
                        </div>
                        <div class="bigimg">
                            <img src="${img}" alt="">
                        </div>
                        <div class="city">
                            ${res.productCity}
                        </div>
                    </div>
                </li>
                `
            $('#info').html(ele)

            $('#comment').html(res.productComment)
        })
})();